import { defineStore } from "pinia";
//pinia仓库写法:组合式API、选择式API写法
import { reqHospitalDeparment, reqAppointment } from "../../api/index.js";
const useDetailStore = defineStore("Detail", {
  state: () => {
    return {
      //存储医院科室的数据
      deparmentArr: [],
      //存储医生
      doctor: [],
    };
  },
  actions: {
    //获取某一个医院科室的数据
    async getDeparment(id) {
      let result = await reqHospitalDeparment(id);
      if (result.code == 1000) {
        this.deparmentArr = result.data;
      }
    },
    //预约
    async getAppointment(hospital_id, detailed_deparment_id) {
      let result = await reqAppointment(hospital_id, detailed_deparment_id);
      if (result.code == 1000) {
        this.doctor = result.data;
      }
    },
  },
  getters: {},
});
//获取仓库的方法对外暴露
export default useDetailStore;
